home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / scripts / coffee.scm.z / coffee.scm
Encoding:
GIMP Script-Fu Script  |  1999-07-21  |  2.6 KB  |  70 lines

  1. ;
  2. ;
  3. ;
  4. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  5. ; At ECS Dept, University of Southampton, England.
  6.  
  7. ; This program is free software; you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 2 of the License, or
  10. ; (at your option) any later version.
  11. ; This program is distributed in the hope that it will be useful,
  12. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ; GNU General Public License for more details.
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program; if not, write to the Free Software
  17. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.  
  20. (define (script-fu-coffee-stain inImage inLayer inNumber inDark)
  21.  
  22.    (set! theImage inImage)
  23.    (set! theHeight (car (gimp-image-height theImage)))
  24.    (set! theWidth (car (gimp-image-width theImage)))
  25.    (set! theNumber inNumber)
  26.    (set! theSize (min theWidth theHeight) )
  27.  
  28.    (while (> theNumber 0) 
  29.        (set! theNumber (- theNumber 1))
  30.        (set! theStain (car (gimp-layer-new theImage theSize theSize RGBA_IMAGE "Stain" 100 
  31.              (if (= inDark TRUE) DARKEN-ONLY NORMAL)          )))
  32.  
  33.   
  34.                               
  35.        (gimp-image-add-layer theImage theStain 0)
  36.        (gimp-selection-all theImage)
  37.        (gimp-edit-clear theImage theStain)
  38.        (let ((blobSize (/ (rand (- theSize 40)) (+ (rand 3) 1)  ) ) )
  39.             (gimp-ellipse-select theImage 
  40.                  (/ (- theSize blobSize) 2)
  41.                  (/ (- theSize blobSize) 2)
  42.          blobSize blobSize REPLACE TRUE 0 FALSE)
  43.        )
  44.        (script-fu-distress-selection theImage theStain (* (+ (rand 15) 1) (+ (rand 15) 1)) (/ theSize 25) 4 2 TRUE TRUE   )
  45.        (gimp-gradients-set-active "Coffee")
  46.        (gimp-blend theImage theStain CUSTOM NORMAL SHAPEBURST-DIMPLED 100 0 REPEAT-NONE FALSE 0 0 0 0 0 0)
  47.        (gimp-layer-set-offsets theStain (- (rand theWidth) (/ theSize 2)) (- (rand theHeight) (/ theSize 2)) theSize)
  48.     )
  49.    (gimp-selection-none theImage)
  50.    (gimp-displays-flush)
  51. )
  52.  
  53. ; Register the function with the GIMP:
  54.  
  55. (script-fu-register
  56.     "script-fu-coffee-stain"
  57.     "<Image>/Script-Fu/Decor/Coffee Stain"
  58.     "foo"
  59.     "Chris Gutteridge"
  60.     "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  61.     "25th April 1998"
  62.     "RGBA RGB"
  63.     SF-IMAGE "The Image" 0
  64.     SF-DRAWABLE "The Layer" 0
  65.     SF-VALUE "Stains:" "3"
  66.     SF-TOGGLE "Darken Only: (better but only for images with alot of white)" TRUE
  67. )
  68.